;
(function (window, angular) {
	'use strict';
	angular.module("Controller.Corruption.DataGover", [])
		.controller("DataGoverCtrl", ["$scope", "$filter", "ybHttp", function ($scope, $filter, ybHttp) {
			$scope.todayStr = $filter("YbDate")(new Date(), 'yyyy/MM/dd EEEE');

			$scope.condition = { month: new Date() };

			$scope.handleSearch = function () {
				getDatas();
			};

			$scope.datas = [];
			$scope.xiaoshouDatas = [];
			$scope.caigouDatas = [];
			$scope.cangchuwuliuDatas = [];
			function getDatas() {
				var service = "device";
				var reqUrl = "/warn/warnStaticsRpt";
				ybHttp.Get(service, reqUrl, { month: $filter("YbDate")($scope.condition.month, 'yyyy-MM') }).then(function (resp) {
					if (resp.code !== 0) {
						ybWidget.ShowMessage(resp, MESG_TYPE.Error);
						return;
					}
					$scope.datas = resp.value;

					$scope.xiaoshouDatas = resp.value.filter(r => r.header == '销售管理')
					$scope.caigouDatas = resp.value.filter(r => r.header == '采购管理')
					$scope.cangchuwuliuDatas = resp.value.filter(r => r.header == '仓储物流')

					$scope.echartsOption1.xAxis[0].data = $scope.xiaoshouDatas.map(r => r.title);
					$scope.echartsOption1.series[0].data = $scope.xiaoshouDatas.map(r => r.warnCount);

					$scope.echartsOption2.xAxis[0].data = $scope.caigouDatas.map(r => r.title);
					$scope.echartsOption2.series[0].data = $scope.caigouDatas.map(r => r.warnCount);

					$scope.echartsOption3.xAxis[0].data = $scope.cangchuwuliuDatas.map(r => r.title);
					$scope.echartsOption3.series[0].data = $scope.cangchuwuliuDatas.map(r => r.warnCount);
				});
			}

			const commonOption = {
				xAxis: [
					{
						type: 'category',
						data: [],
						axisLabel: {
							color: '#98D6FF'
						}
					}
				],
				yAxis: [
					{
						axisLabel: {
							color: '#98D6FF'
						}
					}
				],
				series: [{ name: '数量', type: 'bar' }],
			}

			$scope.echartsOption1 = {
				color: [
					new echarts.graphic.LinearGradient(0, 1, 0, 0, [
						{ offset: 0, color: '#FFBE9E' },
						{ offset: 1, color: '#FFBE65' }
					])
				],
				...angular.copy(commonOption)
			};

			$scope.echartsOption2 = {
				color: [
					new echarts.graphic.LinearGradient(0, 1, 0, 0, [
						{ offset: 0, color: '#00DD86' },
						{ offset: 1, color: '#00D8F0' }
					])
				],
				...angular.copy(commonOption)
			};

			$scope.echartsOption3 = {
				color: [
					new echarts.graphic.LinearGradient(0, 1, 0, 0, [
						{ offset: 0, color: '#36AAFF' },
						{ offset: 1, color: '#00C8FF' }
					])
				],
				...angular.copy(commonOption)
			};

			(function () {
				getDatas();
			})();
		}])
		;
})(window, window.angular);